/*
 * Copyright (c) 2006-2023, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2023-10-11     RT-Thread    first version
 */

#include <rtthread.h>

#define DBG_TAG "main"
#define DBG_LVL DBG_LOG
#include <rtdbg.h>
#include <mygpio.h>
#include <SysInfo.h>
#include <myspi.h>
#include <AD7190.h>
#include <mypwm.h>
#include <OledDisplayCode.h>
#include <mytimer.h>
#include <task.h>
#include <key_board_sample.h>
#include <key_check.h>


rt_uint32_t AD7190_Value;

int main(void)
{
    //led初始化
    GPIO_LED_Init();
//    GPIO_KEY_Init();

    //组合按键初始化
    GPIO_Key_Board_Init();

    //光电传感器初始化
    PhotoElectricity_Init();

    //急停初始化
    EmergencyStop();

    //电机使能引脚初始化PB12 初始关闭
    Motor_Init_Enable();
    //伺服电机失能引脚 PB13 初始开启
    Motor_Init_Disable();

    //at24cxx
    AT24Cxx_Init();
    SystemInfo_Write();
    SystemInfo_Read();

    //硬件定时器
    hwtimer_TIM2_Init();

    //spi、AD7190
    SPI1_Init();
    AD7190_Init();

    //oled初始化
    OledDisplayInit(&u8g2);

    //pwm初始化
    PWM1_Init();

    //注册组合事件
    register_event();

    //创建线程并启动
    thread_create();



    return RT_EOK;
}






